

cls
clear all
* Setting directory*
*cd "~/Dropbox/EUI/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Data"
cd "/Users/mariadelmarcanizaresespadafor/Dropbox/Side projects/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Data"

use  "gambling_data.dta", clear

merge m:1 apuestas_id using "dapuestas_year.dta"

gen treatment=0
replace treatment=1 if metres<500 & year>=year_lic & publico==2 

gen treatment_all=0
replace treatment_all=1 if metres<500 & year>=year_lic

* Prices m2 by district is variable renta

gen Price=alquiler
label variable Price "Rent prices in euros/m2"

* Income by district: 
drop renta
gen renta = .
replace renta = 31 if distrito==4
replace renta = 40 if distrito==1
replace renta = 51 if distrito==14
replace renta = 53 if distrito==15
replace renta = 60 if distrito==5
replace renta = 34 if distrito==17
replace renta = 48 if distrito==6
replace renta = 48 if distrito==8
replace renta = 56 if distrito==11
replace renta = 30 if distrito==10
replace renta = 27 if distrito==3
replace renta = 25 if distrito==18
replace renta = 24 if distrito==13
replace renta = 34 if distrito==12
replace renta = 36 if distrito==7
replace renta = 47 if distrito==9
replace renta = 26 if distrito==21
replace renta = 30 if distrito==20
replace renta = 31 if distrito==19
replace renta = 34 if distrito==16
replace renta = 46 if distrito==2

* Dummy variable for income: Districts with incomes higher to the median==1
drop renta2
gen renta2 = 0 
replace renta2 = 1 if renta>40

/* Variables and placebos about the treatment:

gen treatment_all=0
replace treatment_all=1 if metres<500 & year>year_lic

gen treatment_pl=0
replace treatment_pl=1 if metres<500 & year==year_lic

gen treatment_pl2=0
replace treatment_pl2=1 if metres<500 & year<year_lic

gen treatment_pl3=0
replace treatment_pl3=1 if metres<500 & year<year_lic-1

gen treatmentfut = 0
replace treatmentfut = 1 if metres<500 & year>year_lic+1

*/

*cd "/Users/sergimartinez/Dropbox/EUI/BET HOUSES PROJECT/data/estimates_050121/"

** Publico=1 -> charter schools
** Publico=2 -> public schools

** Renta2=0 -> poorer 
** Renta2=1 -> richer

*use workingfile.dta, clear

drop treat
gen treat=treatment_all

***********************
***********************

*** This makes stata understand data as a panel. And, when applying the xtreg command, adding fixed effects at the observation level. 

xtset school_id year

***********************

*cd "~/Dropbox/EUI/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Estimates"
cd "/Users/mariadelmarcanizaresespadafor/Dropbox/Side projects/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Estimates"

***********************

xtreg Price treat i.year, fe
regsave treat using "Price0.dta", tstat pval ci level(90) replace addlabel (Outcome, Price,Income, All, School, All, Year, 0, Level, 90)

xtreg Price treat i.year, fe
regsave treat using "Price0.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, All, School, All, Year, 0, Level, 95)


*** Charter

xtreg Price treat i.year if publico==1, fe
regsave treat using "Price0.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, All, School, Charter, Year, 0, Level, 90)

xtreg Price treat i.year if publico==1, fe
regsave treat using "Price0.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, All, School, Charter, Year, 0, Level, 95)

***Public

xtreg Price treat i.year if publico==2, fe
regsave treat using "Price0.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, All, School, Public, Year, 0, Level, 90)

xtreg Price treat i.year if publico==2, fe
regsave treat using "Price0.dta", tstat pval ci level(95) append  addlabel (Outcome, Price,Income, All, School, Public, Year, 0, Level, 95)

*** Charter, poor

xtreg Price treat i.year if publico==1 & renta2==0, fe
regsave treat using "Price0.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Poor, School, Charter, Year, 0, Level, 90)

xtreg Price treat i.year if publico==1 & renta2==0, fe
regsave treat using "Price0.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, Poor, School, Charter, Year, 0, Level, 95)

*** Charter, rich

*xtreg Price treat i.year if publico==1 & renta2==1, fe
*regsave treat using "Price0.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Rich, School, Charter, Year, 0, Level, 90)

*xtreg Price treat i.year if publico==1 & renta2==1, fe
*regsave treat using "Price0.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, Rich, School, Charter, Year, 0, Level, 95)

*** Public, poor

xtreg Price treat i.year if publico==2 & renta2==0, fe
regsave treat using "Price0.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Poor, School, Public, Year, 0, Level, 90)

xtreg Price treat i.year if publico==2 & renta2==0, fe
regsave treat using "Price0.dta", tstat pval ci level(95) append addlabel (Outcome, Price, Income, Poor, School, Public, Year, 0, Level, 95)

*** Public, rich

xtreg Price treat i.year if publico==2 & renta2==1, fe
regsave treat using "Price0.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Rich, School, Public, Year, 0, Level, 90)

xtreg Price treat i.year if publico==2 & renta2==1, fe
regsave treat using "Price0.dta", tstat pval ci level(95) append addlabel (Outcome, Price, Income, Rich, School, Public, Year, 0, Level, 95)

use "Price0.dta", clear 

***********************************************************

cls
clear all
* Setting directory*
*cd "~/Dropbox/EUI/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Data"
cd "/Users/mariadelmarcanizaresespadafor/Dropbox/Side projects/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Data"
use "gambling_data.dta", clear

merge m:1 apuestas_id using "dapuestas_year.dta"

gen treatment=0
replace treatment=1 if metres<500 & year<year_lic & publico==2 

gen treatment_all=0
replace treatment_all=1 if metres<500 & year+1>=year_lic

* Prices m2 by district is variable renta

gen Price=alquiler
label variable Price "Rent prices in euros/m2"

* Income by district: 
drop renta
gen renta = .
replace renta = 31 if distrito==4
replace renta = 40 if distrito==1
replace renta = 51 if distrito==14
replace renta = 53 if distrito==15
replace renta = 60 if distrito==5
replace renta = 34 if distrito==17
replace renta = 48 if distrito==6
replace renta = 48 if distrito==8
replace renta = 56 if distrito==11
replace renta = 30 if distrito==10
replace renta = 27 if distrito==3
replace renta = 25 if distrito==18
replace renta = 24 if distrito==13
replace renta = 34 if distrito==12
replace renta = 36 if distrito==7
replace renta = 47 if distrito==9
replace renta = 26 if distrito==21
replace renta = 30 if distrito==20
replace renta = 31 if distrito==19
replace renta = 34 if distrito==16
replace renta = 46 if distrito==2

* Dummy variable for income: Districts with incomes higher to the median==1
drop renta2
gen renta2 = 0 
replace renta2 = 1 if renta>40

/* Variables and placebos about the treatment:

gen treatment_all=0
replace treatment_all=1 if metres<500 & year>year_lic

gen treatment_pl=0
replace treatment_pl=1 if metres<500 & year==year_lic

gen treatment_pl2=0
replace treatment_pl2=1 if metres<500 & year<year_lic

gen treatment_pl3=0
replace treatment_pl3=1 if metres<500 & year<year_lic-1

gen treatmentfut = 0
replace treatmentfut = 1 if metres<500 & year>year_lic+1

*/

*cd "/Users/sergimartinez/Dropbox/EUI/BET HOUSES PROJECT/data/estimates_050121/"

** Publico=1 -> charter schools
** Publico=2 -> public schools

** Renta2=0 -> poorer 
** Renta2=1 -> richer

*use workingfile.dta, clear

drop treat
gen treat=treatment_all

***********************
***********************

*** This makes stata understand data as a panel. And, when applying the xtreg command, adding fixed effects at the observation level. 

xtset school_id year

* Setting directory*
*cd "~/Dropbox/EUI/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Estimates"
cd "/Users/mariadelmarcanizaresespadafor/Dropbox/Side projects/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Estimates"
***********************
***********************

xtreg Price treat i.year, fe
regsave treat using "Price_1.dta", tstat pval ci level(90) replace addlabel (Outcome, Price,Income, All, School, All, Year, 1, Level, 90)

xtreg Price treat i.year, fe
regsave treat using "Price_1.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, All, School, All, Year, 1, Level, 95)


*** Charter

xtreg Price treat i.year if publico==1, fe
regsave treat using "Price_1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, All, School, Charter, Year, 1, Level, 90)

xtreg Price treat i.year if publico==1, fe
regsave treat using "Price_1.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, All, School, Charter, Year, 1, Level, 95)

***Public

xtreg Price treat i.year if publico==2, fe
regsave treat using "Price_1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, All, School, Public, Year, 1, Level, 90)

xtreg Price treat i.year if publico==2, fe
regsave treat using "Price_1.dta", tstat pval ci level(95) append  addlabel (Outcome, Price,Income, All, School, Public, Year, 1, Level, 95)

*** Charter, poor

xtreg Price treat i.year if publico==1 & renta2==0, fe
regsave treat using "Price_1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Poor, School, Charter, Year, 1, Level, 90)

xtreg Price treat i.year if publico==1 & renta2==0, fe
regsave treat using "Price_1.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, Poor, School, Charter, Year, 1, Level, 95)

*** Charter, rich

*xtreg Price treat i.year if publico==1 & renta2==1, fe
*regsave treat using "Price_1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Rich, School, Charter, Year, 1, Level, 90)

*xtreg Price treat i.year if publico==1 & renta2==1, fe
*regsave treat using "Price_1.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, Rich, School, Charter, Year, 1, Level, 95)

*** Public, poor

xtreg Price treat i.year if publico==2 & renta2==0, fe
regsave treat using "Price_1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Poor, School, Public, Year, 1, Level, 90)

xtreg Price treat i.year if publico==2 & renta2==0, fe
regsave treat using "Price_1.dta", tstat pval ci level(95) append addlabel (Outcome, Price, Income, Poor, School, Public, Year, 1, Level, 95)

*** Public, rich

xtreg Price treat i.year if publico==2 & renta2==1, fe
regsave treat using "Price_1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Rich, School, Public, Year, 1, Level, 90)

xtreg Price treat i.year if publico==2 & renta2==1, fe
regsave treat using "Price_1.dta", tstat pval ci level(95) append addlabel (Outcome, Price, Income, Rich, School, Public, Year, 1, Level, 95)

use "Price_1.dta", clear 

replace Year=-1

save "Price_2.dta", replace 


gen ci_lower90 = ci_lower if Level==90
gen ci_upper90 = ci_upper if Level==90
gen ci_lower95 = ci_lower if Level==95
gen ci_upper95 = ci_upper if Level==95

gen out = 0 if Outcome=="Price"

gen inc = 0 if Income=="Poor"
replace inc = 1 if Income=="All" 
replace inc = 2 if Income=="Rich" 

gen charter = 0 if School=="Charter"
replace charter = 1 if School=="Public"
replace charter = 2 if School=="All"

**********************************************************
cls
clear all
* Setting directory*
*cd "~/Dropbox/EUI/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Data"
cd  "/Users/mariadelmarcanizaresespadafor/Dropbox/Side projects/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Data"

use "gambling_data.dta", clear
merge m:1 apuestas_id using "dapuestas_year.dta"
gen treatment=0
replace treatment=1 if metres<500 & year<year_lic & publico==2 

gen treatment_all=0
replace treatment_all=1 if metres<500 & year+2>=year_lic

* Prices m2 by district is variable renta

gen Price=alquiler
label variable Price "Rent prices in euros/m2"


* Income by district: 
drop renta
gen renta = .
replace renta = 31 if distrito==4
replace renta = 40 if distrito==1
replace renta = 51 if distrito==14
replace renta = 53 if distrito==15
replace renta = 60 if distrito==5
replace renta = 34 if distrito==17
replace renta = 48 if distrito==6
replace renta = 48 if distrito==8
replace renta = 56 if distrito==11
replace renta = 30 if distrito==10
replace renta = 27 if distrito==3
replace renta = 25 if distrito==18
replace renta = 24 if distrito==13
replace renta = 34 if distrito==12
replace renta = 36 if distrito==7
replace renta = 47 if distrito==9
replace renta = 26 if distrito==21
replace renta = 30 if distrito==20
replace renta = 31 if distrito==19
replace renta = 34 if distrito==16
replace renta = 46 if distrito==2

* Dummy variable for income: Districts with incomes higher to the median==1
drop renta2
gen renta2 = 0 
replace renta2 = 1 if renta>40

/* Variables and placebos about the treatment:

gen treatment_all=0
replace treatment_all=1 if metres<500 & year>year_lic

gen treatment_pl=0
replace treatment_pl=1 if metres<500 & year==year_lic

gen treatment_pl2=0
replace treatment_pl2=1 if metres<500 & year<year_lic

gen treatment_pl3=0
replace treatment_pl3=1 if metres<500 & year<year_lic-1

gen treatmentfut = 0
replace treatmentfut = 1 if metres<500 & year>year_lic+1

*/

*cd "/Users/sergimartinez/Dropbox/EUI/BET HOUSES PROJECT/data/estimates_050121/"

** Publico=1 -> charter schools
** Publico=2 -> public schools

** Renta2=0 -> poorer 
** Renta2=1 -> richer

*use workingfile.dta, clear

drop treat
gen treat=treatment_all

***********************
***********************

*** This makes stata understand data as a panel. And, when applying the xtreg command, adding fixed effects at the observation level. 

xtset school_id year
cd "/Users/mariadelmarcanizaresespadafor/Dropbox/Side projects/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Estimates"


***********************
***********************

xtreg Price treat i.year, fe
regsave treat using "Price_3.dta", tstat pval ci level(90) replace addlabel (Outcome, Price,Income, All, School, All, Year, 1, Level, 90)

xtreg Price treat i.year, fe
regsave treat using "Price_3.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, All, School, All, Year, 1, Level, 95)


*** Charter

xtreg Price treat i.year if publico==1, fe
regsave treat using "Price_3.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, All, School, Charter, Year, 1, Level, 90)

xtreg Price treat i.year if publico==1, fe
regsave treat using "Price_3.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, All, School, Charter, Year, 1, Level, 95)

***Public

xtreg Price treat i.year if publico==2, fe
regsave treat using "Price_3.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, All, School, Public, Year, 1, Level, 90)

xtreg Price treat i.year if publico==2, fe
regsave treat using "Price_3.dta", tstat pval ci level(95) append  addlabel (Outcome, Price,Income, All, School, Public, Year, 1, Level, 95)

*** Charter, poor

xtreg Price treat i.year if publico==1 & renta2==0, fe
regsave treat using "Price_3.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Poor, School, Charter, Year, 1, Level, 90)

xtreg Price treat i.year if publico==1 & renta2==0, fe
regsave treat using "Price_3.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, Poor, School, Charter, Year, 1, Level, 95)

*** Charter, rich

*xtreg Price treat i.year if publico==1 & renta2==1, fe
*regsave treat using "Price_3.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Rich, School, Charter, Year, 1, Level, 90)

*xtreg Price treat i.year if publico==1 & renta2==1, fe
*regsave treat using "Price_3.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, Rich, School, Charter, Year, 1, Level, 95)

*** Public, poor

xtreg Price treat i.year if publico==2 & renta2==0, fe
regsave treat using "Price_3.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Poor, School, Public, Year, 1, Level, 90)

xtreg Price treat i.year if publico==2 & renta2==0, fe
regsave treat using "Price_3.dta", tstat pval ci level(95) append addlabel (Outcome, Price, Income, Poor, School, Public, Year, 1, Level, 95)

*** Public, rich

xtreg Price treat i.year if publico==2 & renta2==1, fe
regsave treat using "Price_3.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Rich, School, Public, Year, 1, Level, 90)

xtreg Price treat i.year if publico==2 & renta2==1, fe
regsave treat using "Price_3.dta", tstat pval ci level(95) append addlabel (Outcome, Price, Income, Rich, School, Public, Year, 1, Level, 95)

use "Price_3.dta", clear 

replace Year=-2

save "Price_4.dta", replace 


gen ci_lower90 = ci_lower if Level==90
gen ci_upper90 = ci_upper if Level==90
gen ci_lower95 = ci_lower if Level==95
gen ci_upper95 = ci_upper if Level==95

gen out = 0 if Outcome=="Price"

gen inc = 0 if Income=="Poor"
replace inc = 1 if Income=="All" 
replace inc = 2 if Income=="Rich" 

gen charter = 0 if School=="Charter"
replace charter = 1 if School=="Public"
replace charter = 2 if School=="All"

*******************************************************
cls
clear all
* Setting directory*
cd  "/Users/mariadelmarcanizaresespadafor/Dropbox/Side projects/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Data"

use "gambling_data.dta", clear

merge m:1 apuestas_id using "dapuestas_year.dta"

gen treatment=0
replace treatment=1 if metres<500 & year>year_lic & publico==2 

gen treatment_all=0
replace treatment_all=1 if metres<500 & year>year_lic

* Prices m2 by district is variable renta

gen Price=alquiler
label variable Price "Rent prices in euros/m2"

* Income by district: 
drop renta
gen renta = .
replace renta = 31 if distrito==4
replace renta = 40 if distrito==1
replace renta = 51 if distrito==14
replace renta = 53 if distrito==15
replace renta = 60 if distrito==5
replace renta = 34 if distrito==17
replace renta = 48 if distrito==6
replace renta = 48 if distrito==8
replace renta = 56 if distrito==11
replace renta = 30 if distrito==10
replace renta = 27 if distrito==3
replace renta = 25 if distrito==18
replace renta = 24 if distrito==13
replace renta = 34 if distrito==12
replace renta = 36 if distrito==7
replace renta = 47 if distrito==9
replace renta = 26 if distrito==21
replace renta = 30 if distrito==20
replace renta = 31 if distrito==19
replace renta = 34 if distrito==16
replace renta = 46 if distrito==2

* Dummy variable for income: Districts with incomes higher to the median==1
drop renta2
gen renta2 = 0 
replace renta2 = 1 if renta>40

/* Variables and placebos about the treatment:

gen treatment_all=0
replace treatment_all=1 if metres<500 & year>year_lic

gen treatment_pl=0
replace treatment_pl=1 if metres<500 & year==year_lic

gen treatment_pl2=0
replace treatment_pl2=1 if metres<500 & year<year_lic

gen treatment_pl3=0
replace treatment_pl3=1 if metres<500 & year<year_lic-1

gen treatmentfut = 0
replace treatmentfut = 1 if metres<500 & year>year_lic+1

*/

*cd "/Users/sergimartinez/Dropbox/EUI/BET HOUSES PROJECT/data/estimates_050121/"

** Publico=1 -> charter schools
** Publico=2 -> public schools

** Renta2=0 -> poorer 
** Renta2=1 -> richer

*use workingfile.dta, clear

drop treat
gen treat=treatment_all

***********************
***********************

*** This makes stata understand data as a panel. And, when applying the xtreg command, adding fixed effects at the observation level. 

xtset school_id year

***********************
*cd "~/Dropbox/EUI/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Estimates"
cd "/Users/mariadelmarcanizaresespadafor/Dropbox/Side projects/BET HOUSES PROJECT/data/Gambling_Replication_Materials/Estimates"

***********************

xtreg Price treat i.year, fe
regsave treat using "Price1.dta", tstat pval ci level(90) replace addlabel (Outcome, Price,Income, All, School, All, Year, 1, Level, 90)

xtreg Price treat i.year, fe
regsave treat using "Price1.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, All, School, All, Year, 1, Level, 95)


*** Charter

xtreg Price treat i.year if publico==1, fe
regsave treat using "Price1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, All, School, Charter, Year, 1, Level, 90)

xtreg Price treat i.year if publico==1, fe
regsave treat using "Price1.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, All, School, Charter, Year, 1, Level, 95)

***Public

xtreg Price treat i.year if publico==2, fe
regsave treat using "Price1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, All, School, Public, Year, 1, Level, 90)

xtreg Price treat i.year if publico==2, fe
regsave treat using "Price1.dta", tstat pval ci level(95) append  addlabel (Outcome, Price,Income, All, School, Public, Year, 1, Level, 95)

*** Charter, poor

xtreg Price treat i.year if publico==1 & renta2==0, fe
regsave treat using "Price1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Poor, School, Charter, Year, 1, Level, 90)

xtreg Price treat i.year if publico==1 & renta2==0, fe
regsave treat using "Price1.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, Poor, School, Charter, Year, 1, Level, 95)

*** Charter, rich

*xtreg Price treat i.year if publico==1 & renta2==1, fe
*regsave treat using "Price1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Rich, School, Charter, Year, 1, Level, 90)

*xtreg Price treat i.year if publico==1 & renta2==1, fe
*regsave treat using "Price1.dta", tstat pval ci level(95) append addlabel (Outcome, Price,Income, Rich, School, Charter, Year, 1, Level, 95)

*** Public, poor

xtreg Price treat i.year if publico==2 & renta2==0, fe
regsave treat using "Price1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Poor, School, Public, Year, 1, Level, 90)

xtreg Price treat i.year if publico==2 & renta2==0, fe
regsave treat using "Price1.dta", tstat pval ci level(95) append addlabel (Outcome, Price, Income, Poor, School, Public, Year, 1, Level, 95)

*** Public, rich

xtreg Price treat i.year if publico==2 & renta2==1, fe
regsave treat using "Price1.dta", tstat pval ci level(90) append addlabel (Outcome, Price,Income, Rich, School, Public, Year, 1, Level, 90)

xtreg Price treat i.year if publico==2 & renta2==1, fe
regsave treat using "Price1.dta", tstat pval ci level(95) append addlabel (Outcome, Price, Income, Rich, School, Public, Year, 1, Level, 95)

use "Price1.dta", clear 

append using "Price0.dta"

append using "Price_2.dta"

append using "Price_4.dta"

replace Year=Year+2

gen ci_lower90 = ci_lower if Level==90
gen ci_upper90 = ci_upper if Level==90
gen ci_lower95 = ci_lower if Level==95
gen ci_upper95 = ci_upper if Level==95

gen out = 0 if Outcome=="Price"

gen inc = 0 if Income=="Poor"
replace inc = 1 if Income=="All" 
replace inc = 2 if Income=="Rich" 

gen charter = 0 if School=="Charter"
replace charter = 1 if School=="Public"
replace charter = 2 if School=="All"

save "Price2.dta", replace 



